package com.zh.flowable.domain.user;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @author
 * @date 2025/8/22
 */
@NoArgsConstructor
@Data
public class UserInfo implements Serializable {
    private Long id;
    private String username;
    private String nickname;
    private String fullName;
    private List<String> roles;
    private String email;
    private String phone;

    public UserInfo(Long id, String username) {
        this.id = id;
        this.username = username;
        this.roles = Collections.emptyList();
    }
    public UserInfo(Long id, String username, String roles) {
        this.id = id;
        this.username = username;
        if (!roles.isEmpty()){
            this.roles = Arrays.asList(roles.split(","));
        } else {
            this.roles = Collections.emptyList();
        }
    }
}
